Skip to content

cmd/rofl: Fix git repository initialization#543

Merged
abukosek merged 1 commit into
masterfrom
andrej/bugfix/rofl-init-git
Jul 18, 2025
Merged

cmd/rofl: Fix git repository initialization#543
abukosek merged 1 commit into
masterfrom
andrej/bugfix/rofl-init-git

Conversation

@abukosek

Copy link
Copy Markdown
Contributor

Fixes #535.

@abukosek
abukosek force-pushed the andrej/bugfix/rofl-init-git branch from 862bcc6 to 09249e9 Compare July 16, 2025 14:32
@abukosek
abukosek marked this pull request as ready for review July 16, 2025 14:34
@abukosek
abukosek requested a review from matevz July 16, 2025 14:34
Comment thread cmd/rofl/mgmt.go Outdated
}

// Initialize .gitignore.
// Initialize .gitignore in the appropriate path.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's fine if .gitignore lives in the path where the ROFL app is and not the root.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That seems kind of messy :/

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No really. In the monorepos it's perfectly fine to have .gitignore for each module, so this should be fine.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I've updated the code, please have another look :)

Comment thread cmd/rofl/mgmt.go Outdated
gitInitCmd := exec.Command("git", "init")
if err = gitInitCmd.Run(); err != nil {
fmt.Printf("Git repository not initialized: %s.\n", err)
// Save current working directory.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you rely on the git command for initializing the repo, I see no reason why not simply execute git rev-parse to check whether the project folder is already part of the git repo and if not, run init?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was my initial idea, but then realized that we need to modify the .gitignore file and need its path anyway.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Btw, we already have a "get me the Git root" as we need it when determining the project base dir for use with the Docker builder. Please take a look at build/env/base.go which should probably be used instead of reimplementing it.

@netlify

netlify Bot commented Jul 16, 2025

Copy link
Copy Markdown

Deploy Preview for oasisprotocol-cli canceled.

Name Link
🔨 Latest commit 65feade
🔍 Latest deploy log https://app.netlify.com/projects/oasisprotocol-cli/deploys/687923ac8613a4000845e839

@abukosek
abukosek force-pushed the andrej/bugfix/rofl-init-git branch from 09249e9 to 65feade Compare July 17, 2025 16:24
@abukosek
abukosek requested a review from matevz July 18, 2025 08:56
@abukosek
abukosek merged commit e86381a into master Jul 18, 2025
4 checks passed
@abukosek
abukosek deleted the andrej/bugfix/rofl-init-git branch July 18, 2025 16:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

rofl init don't create git repo, if it already exists

3 participants